{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random\n",
    "def geetest_track(distance):\n",
    "        print \"hahaha\"\n",
    "        come_back = random.uniform(-2,3)\n",
    "        cur_loc = 0\n",
    "        track_list = []\n",
    "        magic_ratio = 1\n",
    "        if distance < 50:\n",
    "            magic_ratio = 1\n",
    "        else:\n",
    "            magic_ratio = distance/50.\n",
    "        print magic_ratio\n",
    "        while cur_loc < distance * 1 / 4:\n",
    "            track = random.uniform(2*magic_ratio, 4*magic_ratio)\n",
    "            sleep_time = random.randint(10, 50) / 1000.\n",
    "            track_list.append([track, 0.5, sleep_time])\n",
    "            cur_loc = cur_loc + track\n",
    "            if len(track_list) > 50:\n",
    "                print \"whoops1!\"\n",
    "                print track_list\n",
    "                return\n",
    "        \n",
    "        while cur_loc < distance * 2 / 4:\n",
    "            track = random.uniform(4*magic_ratio, 6*magic_ratio)\n",
    "            sleep_time = random.randint(10, 50) / 5000.\n",
    "            track_list.append([track, 0.3, sleep_time])\n",
    "            cur_loc = cur_loc + track\n",
    "            if len(track_list) > 50:\n",
    "                print \"whoops2!\"\n",
    "                print track_list\n",
    "                return\n",
    "            \n",
    "        while cur_loc < distance * 3 / 4:\n",
    "            track = random.uniform(3*magic_ratio, 5*magic_ratio)\n",
    "            sleep_time = random.randint(10, 50) / 4000.\n",
    "            track_list.append([track, 0.6, sleep_time])\n",
    "            cur_loc = cur_loc + track\n",
    "            if len(track_list) > 50:\n",
    "                print \"whoops3!\"\n",
    "                print track_list\n",
    "                return\n",
    "        \n",
    "        while cur_loc < distance + come_back:\n",
    "            track = random.uniform(2*magic_ratio, 4*magic_ratio)\n",
    "            sleep_time = random.randint(10, 50) / 500.\n",
    "            track_list.append([track, 0.5, sleep_time])\n",
    "            cur_loc = cur_loc + track\n",
    "            if len(track_list) > 50:\n",
    "                print \"whoops4!\"\n",
    "                print track_list\n",
    "                return\n",
    "        \n",
    "        #Final Adjustment\n",
    "        dist = 999\n",
    "        while abs(dist) > 1:\n",
    "            dist  = cur_loc - distance\n",
    "            if dist > 0:\n",
    "                track = -1 * random.uniform(0.5, 2)\n",
    "            else:\n",
    "                track = random.uniform(0.5, 2)\n",
    "            cur_loc = cur_loc + track\n",
    "            sleep_time = random.randint(10, 30) / 100.\n",
    "            track_list.append([track, 0.5, sleep_time])\n",
    "            if len(track_list) > 50:\n",
    "                print \"whoops5!\"\n",
    "                print track_list\n",
    "                return\n",
    "        return track_list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hahaha\n",
      "4.0\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "[[14.464269566584592, 0.5, 0.036],\n",
       " [9.574152040322744, 0.5, 0.027],\n",
       " [10.869245645226684, 0.5, 0.019],\n",
       " [10.351659127474901, 0.5, 0.041],\n",
       " [9.514443419455105, 0.5, 0.017],\n",
       " [23.854056902890534, 0.3, 0.0074],\n",
       " [17.653160147803792, 0.3, 0.0062],\n",
       " [19.35223560446206, 0.3, 0.0038],\n",
       " [12.92574042208101, 0.6, 0.008],\n",
       " [13.133554170738439, 0.6, 0.00375],\n",
       " [12.053751597765043, 0.6, 0.00575],\n",
       " [12.588406493220118, 0.5, 0.078],\n",
       " [11.292590379205668, 0.5, 0.09],\n",
       " [8.146228992828629, 0.5, 0.072],\n",
       " [13.194101465615203, 0.5, 0.088],\n",
       " [15.43856022560939, 0.5, 0.022],\n",
       " [-1.7111706929162458, 0.5, 0.17],\n",
       " [-1.7823567357507895, 0.5, 0.22],\n",
       " [-0.6894989340022635, 0.5, 0.26],\n",
       " [-1.7489889588834224, 0.5, 0.23],\n",
       " [-1.8151736604517428, 0.5, 0.29],\n",
       " [-1.2160967796100048, 0.5, 0.21],\n",
       " [-0.6484530646066641, 0.5, 0.12],\n",
       " [-1.5961695468431882, 0.5, 0.25],\n",
       " [-0.7510153771563826, 0.5, 0.29],\n",
       " [-1.1838216453918322, 0.5, 0.24],\n",
       " [-1.9176373778973457, 0.5, 0.13],\n",
       " [1.0587423973736225, 0.5, 0.11]]"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "geetest_track(200)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
